<%@ page language="java" %>
<%@ page import="com.scalar.chiptrack.utils.ConfigManager"%>
<%@ page import="com.scalar.chiptrack.utils.StringUtils" %>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>

<chiptrack:checkLogon sourcePage="/newproformaInvoice.do"/>

<% String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<% String invoiceId = request.getParameter("invoiceId"); %>
<HTML>
<HEAD><TITLE>ChipTrac - Pro Forma Invoice</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<style type="text/css">
a { text-decoration : none}
</style>

<script language="javaScript">

function sendMail( invoiceId, invoiceNo )
{
    window.open ('<%=chipTracContext%>/proformaInvoiceSendMail.do?invoiceId=' + invoiceId + '&invoiceNo=' + invoiceNo , 'sendProformaMailPopup1','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=800,height=550,resizable=yes');
}

</script>
</HEAD>
<%--<%try{ %>--%>
<BODY bgColor='#ffffff' leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<html:form name="proformaInvoiceForm" type="com.scalar.chiptrack.finance.proformainvoice.forms.ProformaInvoiceForm" action="/newproformaInvoice.do">
<nested:nest property="salesOrder">
    <table align=center width='100%' border='0'>
        <tr>
            <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
            <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
            <td align='right'>
                <font class="NArialW">
                    <table cellSpacing="0" cellPadding="0" border=0 align="right">
                        <tr>
                            <td><a href="javascript:window.print();" title='Click here to print Pro Forma Invoice'><img src="<%=chipTracContext%>/jsp/includes/images/printer_icon_small.gif" width='80' height="60" border="0" alt="Click here to print Pro Forma Invoice"></a></td>
                            <td>&nbsp;</td>
                            <td><a href="javascript:sendMail('<bean:write name="proformaInvoiceForm" property="invoiceId"/>', '<bean:write name="proformaInvoiceForm" property="invoiceNo"/>');" title='Click here to email Pro Forma Invoice'><img src="<%=chipTracContext%>/jsp/includes/images/email1.gif" border="0" alt="Click here to email Pro Forma Invoice"></a></td>
                            <td>&nbsp;&nbsp;&nbsp;</td>
                        </tr>
                    </table>
                </font>
            </td>
        </tr>
        <tr>
            <td width="30%" align="left"><img src="<%=chipTracContext%>/jsp/includes/images/scalar_logo.jpg" height="84" width="200" border=0></td>
            <td width="40%" align=center ><font class='NArialW'><u>Pro Forma Invoice</u></font><br></td>
            <td width="25%" align=right>
                <table>
                    <tr>
                        <td align="left" class="NArialL">
                            <nested:write property="clientName" />
                            <br>
                            <nested:write property="clientAddressAsHTML" filter="false" />&nbsp;
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
<TABLE cellSpacing=0 cellPadding=0 width="95%" border=0 align="center">
    <tr>
        <td colspan='5'><chiptrack:errors styleClass='NArialL'/></td>
    </tr>
    <tr>
        <td colspan='5'><chiptrack:info styleClass='NArialL'/></td>
    </tr>
        <html:hidden property="invoiceId"/>
        <html:hidden property="invoiceNo"/>
    <tr>
        <td bgcolor='#FFFFEE' class="NArialL" valign=top height="100%">
            <table width="100%" height="100%" class="NArialL" border='1' cellspacing='0' bordercolor='#000000'>
                <tr height=30><td class="NArialL" bgcolor="#DEE1E2" >Bill To:</td></tr>
                <tr>
                    <td valign="top">
                        <nested:write property="billingAddressAsHTML" filter="false"/>&nbsp;
                    </td>
                </tr>
            </table>
        </td>
        <td width='1%'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td>
        <td class="NArialL">&nbsp;</td>
        <td width='1%'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td>
        <td bgcolor='#FFFFEE' class="NArialL" valign=top height="100%">
            <table width="100%" height="100%" class="NArialL" border='1' cellspacing='0' bordercolor='#000000'>
                <tr height=30><td class="NArialL" bgcolor="#DEE1E2" >Ship To:</td></tr>
                <tr>
                    <td valign="top">
                    <nested:write property="shippingAddressAsHTML" filter="false"/>&nbsp;
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tR>
        <tr>
            <td class="NArialL">
                <table width="100%" class="NArialL" border='1' cellspacing='0' bordercolor='#000000'>
                    <tr height=30>
                        <td bgcolor='#DEE1E2'>Sales Order#</td>
                        <td bgcolor='#DEE1E2'>Order Date</td>
                    </tr>
                    <tr height=30>
                        <td bgcolor='#FFFFEE'>
                            <nested:write property="salesOrderNo"/>&nbsp;
                        </td>
                        <td bgcolor='#FFFFEE'>
                            <nested:write property="bookingdateAsString"/>&nbsp;
                        </td>
                    </tr>
                </table>
            </td>
            <td width='1%'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td>
            <td class="NArialL">
                <table width="100%" class="NArialL" border='1' cellspacing='0' bordercolor='#000000'>
                    <tr height=30>
                        <td bgcolor='#DEE1E2'>Invoice #</td>
                        <td bgcolor='#DEE1E2'>Invoice Date</td>
                    </tr>
                    <tr height=30>
                        <td bgcolor='#FFFFEE'>
                            <nested:write property="/invoiceNo"/>&nbsp;
                        </td>
                        <td bgcolor='#FFFFEE'>
                            <nested:write property="/invoiceDate"/>&nbsp;
                        </td>
                    </tr>
                </table>
            </td>
            <td width='1%'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td>
            <td class="NArialL">
                <table width="100%" class="NArialL" border='1' cellspacing='0' bordercolor='#000000'>
                    <tr height=30>
                        <td  bgcolor='#DEE1E2'>Sales Person</td>
                        <td bgcolor='#DEE1E2'>Customer PO#</td>
                        <td bgcolor='#DEE1E2'>Del Terms</td>
                        <td bgcolor='#DEE1E2'>pay Terms</td>
                    </tr>
                    <tr height=30>
                        <td bgcolor='#FFFFEE'>
                            <nested:write property="salesPerson"/>&nbsp;
                        </td>
                        <td bgcolor='#FFFFEE'>
                            <nested:write property="customerPO"/>&nbsp;
                        </td>
                        <td bgcolor='#FFFFEE'>
                            <nested:write property="deliveryTerms"/>&nbsp;
                        </td>
                        <td bgcolor='#FFFFEE'>
                            <nested:write property="shippingTerms"/>&nbsp;
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </nested:nest>
    <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tR>
    <tr>
        <td colspan='5'>
            <table width="100%" border=1 cellspacing='0' bordercolor='#000000'>
                <tr height=30>
                    <td class="NArialL" bgcolor='#DEE1E2' align=center>PO Line#</td>
                    <td class="NArialL" bgcolor='#DEE1E2' align=center>UM</td>
                    <td class="NArialL" bgcolor='#DEE1E2' align=center>
                    <bean:message key = "label.mfgPartNumber" /></td>
                    <td class="NArialL" bgcolor='#DEE1E2' align=center>
                    <bean:message key = "label.customerPartNumber" /></td>
                    <td class="NArialL" bgcolor='#DEE1E2' align=center nowrap>Product Description</td>
                    <td class="NArialL" bgcolor='#DEE1E2' align=center>Requested <br>Dock Date</td>
                    <td class="NArialL" bgcolor='#DEE1E2' align=center>Scheduled<br> Ship Date</td>
                    <td class="NArialL" bgcolor='#DEE1E2' align=center>Revised<br> Ship Date</td>
                    <td class="NArialL" bgcolor='#DEE1E2' align=center>Taxable</td>
                    <td class="NArialL" bgcolor='#DEE1E2' align=center >Ship Qty</td>
                    <td class="NArialL" bgcolor='#DEE1E2' align=center> Unit <br>Price</td>
                    <td class="NArialL" bgcolor='#DEE1E2' align=center>Extended<br> Price</td>
                </tr>
                <% double grandTotal = 0d; %>
                <nested:iterate name="proformaInvoiceForm" property="lineItemList" id="proformaLineItem" indexId="lineItemIndex" type="com.scalar.chiptrack.finance.proformainvoice.ProformaInvoiceLineItem" >
                    <nested:equal value="true" property="selected">
                        <tr height=30>
                            <td bgcolor='#FFFFEE' class="NArialL" align=center nowrap>
                                <bean:write name="proformaLineItem" property="poLineItemNo"/>&nbsp;
                            </td>
                            <td bgcolor='#FFFFEE' class="NArialL" align=center nowrap>ea</td>
                            <td bgcolor='#FFFFEE' class="NArialL" align=center nowrap>
                                <bean:write name="proformaLineItem" property="manufacturingPartNo"/>&nbsp;
                            </td>
                            <td bgcolor='#FFFFEE' class="NArialL" align=center nowrap>
                                <bean:write name="proformaLineItem" property="customerPartNo"/>&nbsp;
                            </td>
                            <td bgcolor='#FFFFEE' class="NArialL" align=center width=240>
                                <bean:write name="proformaLineItem" property="description"/>&nbsp;
                            </td>
                            <td bgcolor='#FFFFEE' class="NArialL" align=center nowrap>
                                <bean:write name="proformaLineItem" property="requestDate"/>&nbsp;
                            </td>
                            <td bgcolor='#FFFFEE' class="NArialL" align=center nowrap>
                                <bean:write name="proformaLineItem" property="scheduleDate"/>&nbsp;
                            </td>
                            <td bgcolor='#FFFFEE' class="NArialL" align=center nowrap>
                                <bean:write name="proformaLineItem" property="revisedDate"/>&nbsp;
                            </td>
                            <td bgcolor='#FFFFEE' class="NArialL" align=center nowrap>
                                <bean:write name="proformaLineItem" property="isTaxableAsString"/>&nbsp;
                            </td>
                            <td bgcolor='#FFFFEE' class="NArialL" align=center nowrap>
                                <bean:write name="proformaLineItem" property="qtyPulledStr"/>&nbsp;
                            </td>
                            <td bgcolor='#FFFFEE' class="NArialL" align=right  nowrap>
                                <bean:write name="proformaLineItem" property="unitPriceAsString"/>&nbsp;
                            </td>
                            <td bgcolor='#FFFFEE' class="NArialL" align=right  nowrap>
                                <bean:write name="proformaLineItem" property="amountAsString"/>&nbsp;
                            </td>
                            <%
                                grandTotal += proformaLineItem.getAmountAsDouble();
                            %>
                        </tr>
                    </nested:equal>
                </nested:iterate>
            </table>
        </td>
    </tr>
    <tr>
        <td>&nbsp;</td>
    </tr>
    <tr>
        <td colspan=5 bgcolor='#DEE1E2' align="right" valign=top>
            <font class='NArialL'>
                Grand Total:&nbsp;<%= StringUtils.formatAmount(grandTotal, "$###,###.###") %>&nbsp;
            </font>
        </td>
    </tr>

    <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tR>
    <tr>
        <td colspan="5">
            <table border="0">
                <tr>
                    <td align="center" colspan="5" bgcolor='#DEE1E2' class="NArialL">
                        Banking Information
                    </td>
                </tr>
                <tr>
                    <td bgcolor='#DEE1E2' class="NArialL">Bank Name</td>
                    <td bgcolor='#FFFFEE' class="NArialL"><bean:write name="proformaInvoiceForm" property='bankName'/>&nbsp;</td>
                    <td >&nbsp;</td>
                    <td bgcolor='#DEE1E2' class="NArialL">Address </td>
                    <td bgcolor='#FFFFEE' class="NArialL"><nested:write property='bankAddress1' />&nbsp;</td>
                </tr>
                <tr>
                    <td bgcolor='#DEE1E2' class="NArialL">City </td>
                    <td bgcolor='#FFFFEE' class="NArialL"><nested:write property='bankCity' />&nbsp;</td>
                    <td>&nbsp;</td>
                    <td bgcolor='#DEE1E2' class="NArialL">State</td>
                    <td bgcolor='#FFFFEE' class="NArialL"><nested:write property='bankState' />&nbsp;</td>
                </tr>
                <tr>
                    <td bgcolor='#DEE1E2' class="NArialL">Zip Code</td>
                    <td bgcolor='#FFFFEE' class="NArialL"><nested:write property='bankZipCode' />&nbsp;</td>
                    <td>&nbsp;</td>
                    <td bgcolor='#DEE1E2' class="NArialL">Country</td>
                    <td bgcolor='#FFFFEE' class="NArialL"><nested:write property='bankCountry' />&nbsp;</td>
                </tr>
                <tr>
                    <td bgcolor='#DEE1E2' class="NArialL">ABA</td>
                    <td bgcolor='#FFFFEE' class="NArialL"><bean:write name="proformaInvoiceForm" property='aba' />&nbsp;</td>
                    <td>&nbsp;</td>
                    <td bgcolor='#DEE1E2' class="NArialL">Acct</td>
                    <td bgcolor='#FFFFEE' class="NArialL"><bean:write name="proformaInvoiceForm" property='acct'/>&nbsp;</td>
                </tr>
                <tr>
                    <td bgcolor='#DEE1E2' class="NArialL">Swift code</td>
                    <td bgcolor='#FFFFEE' class="NArialL"><bean:write name="proformaInvoiceForm" property='swiftcode'/>&nbsp;</td>
                    <td colspan="3">&nbsp;</td>
                </tr>
            </table>
        </td>
    </tr>
    </html:form>
   <BR><BR><BR>
    <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=25></td></tR>
    <tr>
        <td colspan='5'>
            <table border='0' width='100%' >
                <td width='10%' class='NArialL' align=center>Signature:</td>
                <td width='50%' class='NArialL' align=left ><hr></td>
                <td width='5%' class='NArialL' align=center>&nbsp;</td>
                <td width='10%' class='NArialL' align=right>Date:</td>
                <td width='20%' class='NArialL' align=center><hr></td>
            </table>
        </td>
    </tr>
    <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=25></td></tR>
</TABLE>
</body>
</html>
